import * as Type from './type'
import axios from 'axios'

export const searchFocus = ()=>({
  type: Type.SEARCH_FOCUS
})

export const searchBlur = ()=>({
  type: Type.SEARCH_BLUR
})
const changeList = (data) =>({
  type: Type.CHANGE_LIST,
  totalPage: Math.ceil(data.length/10),
  data
})

export const mouseEnter = ()=>({
  type: Type.MOUSE_ENTER
})

export const mouseLevea = ()=>({
  type: Type.MOUSE_LEVEA
})

export const changePage = (page) => ({
  type: Type.CHANGE_PAGE,
  page
})
export const getList = ()=> {
  return (dispatch) => {
    axios.get('/api/headerList.json').then((res)=>{
      const data = res.data
      dispatch(changeList(data.data))
    }).catch((e)=>{
      console.log(e)
    })
  }
}